﻿using System;
using JetBrains.Annotations;

namespace StreetPacMan.Server
{
    public interface IDistanceCalculator
    {
        bool AreCloseWithinXMeters(double lat1, double lng1, double lat2, double lng2, int meters);
    }

    [UsedByIoc]
    public class DistanceCalculator : IDistanceCalculator
    {
        public bool AreCloseWithinXMeters(double lat1, double lng1, double lat2, double lng2, int meters)
        {
            var distanceInMeters = Math.Sqrt(Math.Pow(lng1 - lng2, 2) + Math.Pow(lat1 - lat2, 2)) * 100000;
            return distanceInMeters < meters;
        }
    }
}